set layout params programmatically android with dp values

110

set layout params programmatically android with dp values -

float factor = getResources().getDisplayMetrics().density;
int pxWidth = (int)(dpWidth * factor);
int pxHeight = (int)(dpHeight * factor);
LinearLayout.LayoutParams layoutParams = 
  new LinearLayout.LayoutParams(pxWidth, pxHeight);

Comments

Submit
0 Comments